package com.skytech.component.monitor.data;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class WaterPollutionDataService {
    @Autowired
    private  WaterPollutionDataDAO waterPollutionDataDAO;

    public List<WaterPollutionData> listWaterPollutionData(){
       List<WaterPollutionData> waterPollutionDataList= waterPollutionDataDAO.findBySiteName();

       List<WaterPollutionData> waterPollutionDatas=new ArrayList<>();
       if(!waterPollutionDataList.isEmpty()){
           for (WaterPollutionData w:waterPollutionDataList) {
                WaterPollutionData waterPollutionData=waterPollutionDataDAO.findOneBySiteName(w.getSiteName());
                if(null!=waterPollutionData){
                    waterPollutionDatas.add(waterPollutionData);
                }
           }
       }

       return waterPollutionDatas;
    }
}
